<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    const result = [1, 2, 3, 4, 5]

    console.log(result.reduce((a, b) => a - b));

    Array.prototype.reduce2 = function (callback) {
        let total
        for (let i = 0; i < this.length; i++) {
            if (i === 0) {
                total = this[i]
            } else {
                total = callback(total, this[i])
            }

        }
        return total
    }

    console.log(result.reduce2((a, b) => a + b));
</script>
</body>
</html>
